package com.huang.consumer_mall.web;

import com.github.pagehelper.PageInfo;
import com.huang.consumer_mall.model.Commgory;
import com.huang.consumer_mall.model.PageCondition;
import com.huang.consumer_mall.service.CommgoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CommgoryController {
    @Autowired
    protected CommgoryService commgoryService;

    @PostMapping("/api/commgory/findListName")   //查询商品分类的名字
    public  List<String> findListName(){
        return commgoryService.findListName();
    }



    @PostMapping("/api/commgory/findList1")      //查询所有的商品分类
    public List<Commgory> findList1(){
        return commgoryService.findList1();
    }

    @PostMapping("/api/customer/commgory/findList1")      //查询所有的商品分类
    public List<Commgory> findList2(){
        return commgoryService.findList1();
    }



    @PostMapping("/api/commgory/findViewCommgory")   //按照分页查询所有的商品分类
    public PageInfo<Commgory> findViewCommgory(@RequestBody PageCondition<Commgory> condition){
        return commgoryService.page1(condition);}
    @PostMapping("/api/commgory/deleteCommgory")
    public String deleteById(@RequestBody Commgory commgory){     //删除商品分类，触发器触发删除级联下商品
         commgoryService.deleteById(commgory);
         return "success";
    }
    @PostMapping("/api/commgory/commgoryAdd")   //添加商品分类
    public String insert(@RequestBody Commgory commgory){
        return "success";
    }
    @PostMapping("/api/commgory/commgoryUpdate")  //更新商品分类
    public String  update(@RequestBody Commgory commgory){
        commgoryService.update(commgory);
        return "success";
    }

    @PostMapping("/api/commgory/commgoryFindOne")
    public Commgory findOne(@RequestBody Commgory commgory){
        return commgoryService.findOne(commgory);
    }
}
